API Documentation
Public Member Functions | List of all members
nkGraphics::NodeManager Class Referencefinal

Manages the nodes available in the component. More...

Inheritance diagram for nkGraphics::NodeManager:

Public Member Functions

Nodecreate ()
 
NodecreateOrRetrieve (const nkMemory::StringView &name)
 
Nodeget (const nkMemory::StringView &name) const
 
NodegetByIndex (unsigned int index) const
 
void rename (const nkMemory::StringView &currentName, const nkMemory::StringView &newName)
 
void erase (const nkMemory::StringView &name)
 

Detailed Description

Manages the nodes available in the component.

At all times, the manager is responsible for memory returned. External code should never free it.

The manager is the entry point when starting a graph. By creating a node through createOrRetrieve, a local root can be obtained.
To construct a graph, it is either possible to instanciate a new node through the Manager and add it to the graph, or call graph managing functions on an existing node.

Member Function Documentation

◆ create()

Node* nkGraphics::NodeManager::create ( )

Creates a node.
This version of the function will use an internal counter to create names shaped like "Node_0", "Node_1". The counter gets incremented as the function gets called.

Returns
A new node. The manager owns the memory allocated, external code should not free it. See erase().
Remarks
This function can be used when names are not relevant in the graph creation.

◆ createOrRetrieve()

Node* nkGraphics::NodeManager::createOrRetrieve ( const nkMemory::StringView name)

Creates if unavailable, or retrieves if available, a node.

Parameters
nameThe name of the node to retrieve.
Returns
The node requested, possibly freshly created. The manager owns memory returned, external code should not free it. See erase().

◆ get()

Node* nkGraphics::NodeManager::get ( const nkMemory::StringView name) const

Retrieves an existing node.

Parameters
nameThe name of the node wanted.
Returns
The node requested if available, nullptr else.

◆ getByIndex()

Node* nkGraphics::NodeManager::getByIndex ( unsigned int  index) const

Retrieves a node given an index. Note that as the internal memory is changed, an index can map to different nodes over different calls. Mainly used to loop over all nodes in one go.

Parameters
indexThe index of the node to retrieve.
Returns
The node requested if available, nullptr else.

◆ rename()

void nkGraphics::NodeManager::rename ( const nkMemory::StringView currentName,
const nkMemory::StringView newName 
)

Renames a node, changing both its name and the way it is accessed through the manager.

Parameters
currentNameThe name of the node to rename.
newNameThe name to attach.

◆ erase()

void nkGraphics::NodeManager::erase ( const nkMemory::StringView name)

Erases and frees the memory of a node.

Parameters
nameThe name of the node to erase.

The documentation for this class was generated from the following file: